package com.xjscrm.console.service.customer.group.impl;

import com.xjscrm.common.constant.ResponseMsg;
import com.xjscrm.common.exception.BusinessException;
import com.xjscrm.common.result.ResponseCode;
import com.xjscrm.console.param.group.BatchDelWwGroupClassifyDto;
import com.xjscrm.console.service.customer.group.WwGroupClassifyBatchService;
import com.xjscrm.console.service.customer.group.WwGroupClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WwGroupClassifyBatchServiceImpl implements WwGroupClassifyBatchService {

    @Autowired
    private WwGroupClassifyService wwGroupClassifyService;

    @Override
    public void batchDelWwGroupClassify(BatchDelWwGroupClassifyDto batchDelWwGroupClassifyDto) {

        if (batchDelWwGroupClassifyDto.getIds() == null || batchDelWwGroupClassifyDto.getIds().isEmpty()) {
            throw new BusinessException(ResponseCode.BUSINESS_EXCEPTION, ResponseMsg.PARAMETER_ERROR);
        }

        for (Long id : batchDelWwGroupClassifyDto.getIds()) {
            try {
                batchDelWwGroupClassifyDto.setId(id);
                wwGroupClassifyService.delWwGroupClassify(batchDelWwGroupClassifyDto);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
